#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int R = 1440;
const int C = 100;

int n, m;
int a[R + 5][C + 5], b[R + 5][C + 5];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) {
    int x, y;
    cin >> x >> y;
    b[x][y]++;
  }
  rep(i, 1, m) {
    int x, y;
    cin >> x >> y;
    a[x][y]++;
  }
  ll sum = 0;
  int cnt = 0;
  per(i, R, 1) {
    rep(j, 0, C) {
      per(k, j, 0) {
        int x = min(a[i][k], b[i][j]);
        if (x) {
          a[i][k] -= x;
          b[i][j] -= x;
          cnt += x;
          sum += 1ll * x * (i * 500 + k * 2);
        }
        if (!b[i][j]) break;
      }
      b[i - 1][j] += b[i][j];
    }
  }
  cout << cnt << ' ' << sum;
  return 0;
}